<template>
  <div class="editReturnMater" @click.stop="aotuTab=false">
    <div class="dropdown">
      <jc-button
        :btn-arr="['save', 'sub', 'remove', 'option', 'pass', 'push', 'reload', 'list', !list.length && 'check']"
        :disab-arr="['close', 'cancel', 'toExcel', 'freeze']"
        :fbillno="prodValue.fbillNo"
        :list="'/returnMaterList'"
        @refresh="queryTSalOrderNtry"
        @save="insert"
        @audit="audit(1)"
        @noAudit="audit(2)"
        @submit="insert(1)"
        @noSubmit="submit(2)"
        @del="delPublic"
        @startUsing="using(1)"
        @forbidden="using(2)"
        @check="check('up')"
        @check1="check('down')"
        @handleCom1="queryReportForm(1)"
        @handleCom2="queryReportForm(2)"
        @pushDown="pushDown"
      />
    </div>
    <el-tabs v-model="activeName" class="tabs" @tab-click="handleOther">
      <el-tab-pane :label="$t('market.info')" name="first">
        <el-form ref="purchaseRef" :model="prodValue" label-width="100px">
          <el-form-item :label="$t('market.state')" prop="fnote">
            <el-tag :type="prodValue.stateColor">{{ prodValue.fdocumentstatus }}</el-tag>
          </el-form-item>
          <el-form-item :label="$t('market.billType')" prop="fbilltypeId">
            <el-select
              v-model.trim="prodValue.fbilltype"
              size="mini"
              disabled
            />
          </el-form-item>
          <!--          <el-form-item label="采购组织">-->
          <!--            <el-input v-model.trim="prodValue.fpurchaseorg" disabled />-->
          <!--          </el-form-item>-->
          <el-form-item :label="$t('market.billNo')">
            <el-input v-model="prodValue.fbillNo" disabled size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.returnMaterDate')" prop="fdate">
            <el-date-picker
              v-model="prodValue.fdate"
              type="date"
              value-format="yyyy-MM-dd"
              size="mini"
              :disabled="isDisabled"
              style="width: 163px"
            />
          </el-form-item>
          <el-form-item :label="$t('market.returnMaterCause')" prop="fmrMode">
            <el-select v-model.trim="prodValue.fmrreasonid" :disabled="isDisabled" size="mini">
              <el-option v-for="item in storeData" :key="item.fid" :label="item.fname" :value="item.fid" />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('market.stocker')" prop="fstockerId">
            <el-autocomplete
              v-model.trim="prodValue.fstocker"
              highlight-first-item
              popper-class="my-autocomplete"
              :fetch-suggestions="querySearch11"
              size="mini"
              :disabled="isDisabled"
              @focus="queryStocker"
              @select="stockerData"
            >
              <i
                slot="suffix"
                class="el-input__icon el-icon-search"
                @click="openStocker=true"
              />
              <template slot-scope="{ item }">
                <div class="name">{{ item.fuserName }}</div>
              </template>
            </el-autocomplete>
          </el-form-item>
          <el-form-item :label="$t('market.purchaser')" prop="fpurchaser">
            <el-input v-model.trim="prodValue.fpurchaser" disabled size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.supplier')" prop="fsupplier">
            <el-input v-model.trim="prodValue.fsupplier" disabled size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.note')" prop="fnote">
            <el-input v-model.trim="prodValue.fdescription" :disabled="isDisabled" placeholder="请填写备注" size="mini" />
          </el-form-item>
        </el-form>
        <div style="margin-bottom: 5px;margin-top: 10px">
          <el-button size="mini" :disabled="isDisabled" @click="newLine(1)">{{ $t('btn.newHang') }}<!--新增行--></el-button>
          <el-button :disabled="isDisabled" size="mini" @click="newLine(2)">{{ $t('btn.delHang') }}<!--删除行--></el-button>
          <el-button :disabled="isDisabled" size="mini" @click="batchFill">{{ $t('btn.batchFill') }}<!--批量填充--></el-button>
        </div>
        <!--明细表格-->
        <div :label="$t('market.detailInfo')" class="tabOne" name="first">
          <jc-table
            :table-data="tableData"
            :table-header="tableHeader"
            serial
            :get-summaries="getSummaries"
            show-summary
            :table-height="tableHeight"
            @cellClick="cellClick"
            @rowClick="rowClick"
          >
            <!--  物料编码-->
            <template v-slot:billSlot="col">
              <el-input
                v-model.trim="col.scope.row.fnumber"
                :disabled="isDisabled"
                size="mini"
                @input="getAtuo(col.scope.$index, col.scope.row.fnumber)"
              >
                <i
                  slot="prefix"
                  class="iconfont icon-jin-rud-ao-bo"
                  @click="sonJumpMateriel(col.scope.row.fnumber)"
                />
                <i
                  slot="suffix"
                  class="el-input__icon el-icon-search"
                  @click="materia(col.scope.$index)"
                />
              </el-input>
              <div v-if="aotuTab && indexSelf === col.scope.$index" :class="indexSelf<7 ? 'tabPosit': 'tabPosit1'">
                <number-code :fnumber="fnumber" @material="materialData" />
              </div>
            </template>
            <!--实退数量-->
            <template v-slot:tagSlot="col">
              <el-input-number
                v-model="col.scope.row.frmrealqty"
                :min="0"
                :disabled="isDisabled"
                size="mini"
                @change="numQty(col.scope.$index)"
              />
            </template>
            <!--仓库-->
            <template v-slot:btnStates="col">
              <el-input
                v-model="col.scope.row.fstock"
                size="mini"
                :disabled="isDisabled"
              >
                <i
                  slot="suffix"
                  class="el-input__icon el-icon-search"
                  @click="handleWarehouse(col.scope.$index, 1)"
                />
              </el-input>
            </template>
            <!--收货仓库-->
            <template v-slot:btnState="col">
              <el-input
                v-model="col.scope.row.freceivestock"
                size="mini"
                :disabled="isDisabled"
              >
                <i
                  slot="suffix"
                  class="el-input__icon el-icon-search"
                  @click="handleWarehouse(col.scope.$index, 2)"
                />
              </el-input>
            </template>
            <!--备注-->
            <template v-slot:btnSlot="col">
              <el-input
                v-model="col.scope.row.fpaeztext1"
                size="mini"
                :disabled="isDisabled"
              />
            </template>
            <!--库位-->
            <template v-slot:text3Slot="col">
              <el-select v-model="col.scope.row.fcodefnumber" size="mini" @change="handelCode(col.scope.$index)">
                <el-option v-for="item in col.scope.row.codes" :key="item.fid" :label="item.positionfnumber" :value="item.fnumber" />
              </el-select>
            </template>
            <!--客户订单号-->
            <template v-slot:orderSlot="col">
              <el-input
                v-model="col.scope.row.fpaeztext"
                size="mini"
                :disabled="isDisabled"
              />
            </template>
            <!--库存组织-->
            <template v-slot:operaSlot="col">
              <el-select v-model="col.scope.row.fstockorgid" :disabled="isDisabled">
                <el-option
                  v-for="option in teamList"
                  :key="option.fid"
                  :label="option.fname"
                  :value="option.fid"
                />
              </el-select>
            </template>
          </jc-table>
        </div>
      </el-tab-pane>
      <el-tab-pane :label="$t('market.fince')" name="two">
        <el-form ref="purchaseRef1" :model="prodValue" label-width="100px">
          <!--          <el-form-item label="结算组织">-->
          <!--            <el-input v-model.trim="prodValue.fsettleorg" disabled />-->
          <!--          </el-form-item>-->
          <el-form-item :label="$t('market.settleType')" prop="fsettlemodeId">
            <el-autocomplete
              v-model.trim="prodValue.fsettletype"
              highlight-first-item
              popper-class="my-autocomplete"
              :fetch-suggestions="querySearch8"
              size="mini"
              :disabled="isDisabled"
              @focus="getBasicUnit('SX_SETTLETYPE')"
              @select="selUnit"
            >
              <i
                slot="suffix"
                class="el-input__icon el-icon-search"
                @click="cliUnit('SX_SETTLETYPE')"
              />
              <template slot-scope="{ item }">
                <div class="name">{{ item.fname }}</div>
              </template>
            </el-autocomplete>
          </el-form-item>
          <el-form-item :label="$t('market.settleCurr')" prop="fsettlecurrId">
            <el-input v-model.trim="prodValue.fsettlecurr" disabled size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.paymentClause')" prop="fpayconditionId">
            <el-autocomplete
              v-model.trim="prodValue.fpaycondition"
              highlight-first-item
              popper-class="my-autocomplete"
              :fetch-suggestions="querySearch18"
              :disabled="isDisabled"
              size="mini"
              :popper-append-to-body="false"
              @focus="getBasicUnit('SX_PAYCONDITION')"
              @select="selUnit"
            >
              <i
                slot="suffix"
                class="el-input__icon el-icon-search"
                @click="cliUnit('SX_PAYCONDITION')"
              />
              <template slot-scope="{ item }">
                <div class="name">{{ item.fname }}</div>
              </template>
            </el-autocomplete>
          </el-form-item>
          <el-form-item :label="$t('market.priceList')" prop="fpricelist">
            <el-input v-model.trim="prodValue.fpricelist" size="mini" disabled />
          </el-form-item>
          <el-form-item :label="$t('market.billamount')">
            <el-input v-model.trim="prodValue.fbillamount" size="mini" disabled />
          </el-form-item>
          <el-form-item :label="$t('market.billtaxamount')">
            <el-input v-model.trim="prodValue.fbilltaxamount" size="mini" disabled />
          </el-form-item>
          <el-form-item :label="$t('market.billallamount')">
            <el-input v-model.trim="prodValue.fbillallamount" size="mini" disabled />
          </el-form-item>
          <el-form-item :label="$t('market.localCurr')">
            <el-input v-model.trim="prodValue.flocalcurr" size="mini" disabled />
          </el-form-item>
          <el-form-item :label="$t('market.exchangeType')" prop="fexchangetypeId">
            <el-input v-model.trim="prodValue.fexchangetype" disabled size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.exchangeRate')">
            <el-input v-model.trim="prodValue.fexchangerate" disabled size="mini" />
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane :label="$t('market.other')" name="log">
        <jc-marker
          ref="log"
          :fnumber="prodValue.fbillNo"
          other-height="68vh"
          :other-url-object="otherUrlObject"
        />
      </el-tab-pane>
    </el-tabs>
    <el-dialog
      v-dialogDrag
      :title="$t('market.checkBill')"
      model
      :visible.sync="isdanjuDialog"
      :close-on-click-modal="false"
      width="600px"
      top="5vh"
      center
      append-to-body
    >
      <div style="text-align: center;height: 100px;line-height: 100px">
        <el-radio-group v-model="orderLX" @change="orderWat">
          <el-radio v-for="item in receipts" :key="item" :label="item">
            {{ item }}
          </el-radio>
        </el-radio-group>
      </div>
      <hr>
      <div style="text-align: center;">
        {{ $t('market.rule') }}
        <el-input v-model="convert" size="mini" disabled style="width: 178px;margin-bottom: 5px;" />
        <br>
        {{ $t('market.billType') }}
        <el-select
          v-model.trim="fbillTypeId"
          size="mini"
          filterable
        >
          <el-option
            v-for="(item, index) in billTypeData"
            :key="index"
            :label="item.fname"
            :value="item.fid"
          />
        </el-select>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="isdanjuDialog = false">{{ $t('btn.cancel') }}</el-button>
        <el-button size="mini" type="primary" @click="pushDownOrder()">
          {{ $t('btn.confirm') }}
        </el-button>
      </span>
    </el-dialog>
    <!--    仓管员-->
    <stocker v-if="openStocker" @stocker="stockerData" />
    <!--    仓库-->
    <selectCK v-if="seleceVisiblit" @client="selectData" />
    <!--    物料弹窗-->
    <material v-if="isMateria" @material="materialData" />
    <!--  数据字典弹窗  -->
    <unit v-if="unitVisabled" :msg="funit" @unit="selUnit" />
    <upDown v-if="upDownVis" :msg="cha" :fentryid="fentryData" @client="upDownVis=false" />
  </div>
</template>
<script>
import {
  updateMrb,
  queryPurMrbListDetails,
  purMrbAudit,
  purMrbUnAudit,
  purMrbSubmit,
  purMrbAuSubmit, purMrbdisable, purMrbUndisable, purMrbDelete
} from '@/api/purchaseManagement/returnMaterial'
import jumpMateriel from '@/components/JumpMateriel'
import mixinsImg from '@/views/market/marketManage/createMarkerOrder/components/mixinsImg'
import { toMxBmina } from '@/components/ToMxamineState'
import autocomplete from '@/views/market/marketManage/createMarkerOrder/components/autocomplete'
import jcMarker from '@/components/marker'
import { queryViewItem } from '@/api/marketManage/marketOrder'
import jcButton from '@/components/Button'
import bility from '@/mixin/Operability'
import { returnPushToFinPayable } from '@/api/purchaseManagement/putStorage'

export default {
  name: 'EditReturnMater',
  components: {
    jcMarker,
    upDown: () => import('@/components/upDown'),
    stocker: () => import('@/views/purchasing/putStorage/editStorage/component/stocker'),
    selectCK: () => import('@/views/production/collect/components/seleceCK'),
    material: () => import('@/views/market/marketManage/createMarkerOrder/components/material'),
    numberCode: () => import('@/components/NumberCode'),
    jcButton,
    unit: () => import('@/views/basic/createMateriel2/components/unit')
  },
  mixins: [jumpMateriel, mixinsImg, autocomplete, bility],
  props: {
    list: {
      type: Array,
      default: function() {
        return []
      }
    }
  },
  data() {
    return {
      isdanjuDialog: false,
      orderLX: this.$t('menu.payable'),
      receipts: [this.$t('menu.payable')], // '应付单'
      fbillTypeId: 178,
      convert: this.$t('market.cgrkztk'),
      billTypeData: [], // 采购订单单据
      upDownVis: false,
      cha: '',
      fentryData: [],
      funit: '',
      activeName: 'first', // 基本信息
      activeName1: 'first', // 明细信息
      openStocker: false, // 仓管员
      isMateria: false, // 物料
      isDisabled: false,
      unitVisabled: false,
      fnumber: '',
      aotuTab: false,
      otherUrlObject: {},
      prodValue: {}, // 表单数据
      tableHeight: '69vh',
      indexSelf: 0,
      storeData: [],
      tableData: [],
      tableHeader: [
        { label: this.$t('market.fmaterial'), type: 'bill', prop: 'fnumber', width: '150px' },
        { label: this.$t('market.fmodel'), prop: 'fmodel', width: '120px' },
        { label: this.$t('shop.fname2'), prop: 'fname' },
        { label: this.$t('shop.fspecificaTion'), prop: 'fspecificaTion', width: '120px' },
        { label: this.$t('market.fdescripTion'), prop: 'fdescripTion', minWidth: '200px' },
        { label: this.$t('market.funit'), prop: 'funit', width: '80' },
        { label: this.$t('market.mustqty2'), prop: 'frmmustqty', width: '80px' },
        { label: this.$t('market.realqty2'), type: 'tag', prop: 'frmrealqty', width: '80px' },
        { label: this.$t('market.fprice'), prop: 'fprice', width: '70' },
        { label: this.$t('market.billamount'), prop: 'famount', width: '70' },
        { label: this.$t('market.ftaxPrice'), prop: 'ftaxprice', width: '70' },
        { label: this.$t('market.billallamount'), prop: 'fallamount', width: '70' },
        { label: this.$t('market.ftaxRate'), prop: 'ftaxrate', width: '80' },
        { label: this.$t('market.billtaxamount'), prop: 'ftaxamount', width: '80' },
        { label: this.$t('market.stock2'), type: 'states', prop: 'fstock', minWidth: '100px' },
        { label: this.$t('market.receivestock'), type: 'state', prop: 'freceivestock', minWidth: '100px' },
        { label: this.$t('market.stockUnit'), prop: 'fstockunit', width: '70' },
        { label: this.$t('market.storageLoca'), type: 'text3', prop: 'fcodefnumber', width: '100' },
        { label: this.$t('market.storageQty'), prop: 'fcodeQty', width: '80' },
        // { label: '库存组织', type: 'operate', prop: 'fstockorg', width: '120' },
        { label: this.$t('market.paezText1'), type: 'order', prop: 'fpaeztext', minWidth: '100px' },
        { label: this.$t('market.chargeunit'), prop: 'fpriceunit' },
        { label: this.$t('market.chargeQty'), prop: 'fpriceunitqty' },
        { label: this.$t('market.usedepid'), prop: 'fdeptName' },
        { label: this.$t('market.note'), type: 'btn', prop: 'fpaeztext1', minWidth: '100px' }
      ],
      seleceVisiblit: false // 仓库
    }
  },
  created() {
    if (this.$route.params.id) {
      this.queryTSalOrderNtry() // 获取订单列表数据
      this.handleGetMaterials()
    }
    this.tableHeight = window.innerWidth > 1440 ? 'calc(100vh - 290px)' : '69vh'
  },
  methods: {
    // 查询退料原因列表
    async handleGetMaterials() {
      const { data: RES } = await queryViewItem({ viewName: 'SX_MRREASON' })
      this.storeData = RES.list
    },
    // 输入物料编码
    getAtuo(index, fnumber) {
      this.indexSelf = index
      this.aotuTab = true
      var vm = this
      clearTimeout(vm.timer) // 清除未执行的代码，重置回初始化状态
      vm.timer = setTimeout(() => {
        this.fnumber = fnumber
      }, 600)
    },
    // 修改采购订单
    insert(ev) {
      if (this.prodValue.fstockerId === 0) {
        this.$message.warning('请选择仓管员')
        return false
      }
      const DATA = this.prodValue
      this.prodValue.fbillno = this.prodValue.fbillNo
      this.prodValue.details = this.tableData
      updateMrb(DATA).then(res => {
        if (res.code === 0) {
          ev === 1 ? this.submit(1) : this.queryTSalOrderNtry()
          this.$message({ showClose: true, message: res.message, type: 'success' })
        } else {
          this.$confirm(res.message, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'error'
          })
        }
      })
    },
    // 获取订单列表数据
    async queryTSalOrderNtry() {
      const id = this.$route.params.id
      const DATA = { fid: id }
      const { data: RES } = await queryPurMrbListDetails(DATA)
      this.prodValue = toMxBmina(RES)
      this.otherUrlObject = RES
      this.isDisabled = this.prodValue.fdocumentstatus === this.$t('market.state1') || this.prodValue.fdocumentstatus === this.$t('market.state2')
      this.tableData = RES.details
      this.tableData.map(res => {
        res.fcodeQty = res.codes?.[0]?.fqty || 0
      })
    },
    // 打开仓库弹窗
    handleWarehouse(index, ev) {
      this.indexSelf = index
      this.stockQF = ev
      this.seleceVisiblit = true
    },
    // 获取仓库数据
    selectData(ev) {
      if (ev.fstockId && this.stockQF === 1) {
        this.tableData[this.indexSelf].fstockid = ev.fstockId
        this.tableData[this.indexSelf].fstock = ev.fname
      } else {
        this.tableData[this.indexSelf].freceivestockid = ev.fstockId
        this.tableData[this.indexSelf].freceivestock = ev.fname
      }
      this.seleceVisiblit = false
    },
    // 仓管员
    stockerData(item) {
      if (item.fuserId) {
        this.prodValue.fstockerId = item.fuserId
        this.prodValue.fstocker = item.fuserName
      }
      this.openStocker = false
    },
    // 打开物料弹窗
    materia(index) {
      this.isMateria = true
      this.indexSelf = index
    },
    // 获取物料
    materialData(ev) {
      if (ev.fnumber) {
        const item = this.tableData[this.indexSelf]
        item.fmodel = ev.fmodel
        item.fnumber = ev.fnumber
        item.fmaterialId = ev.fmaterialId
        item.fspecificaTion = ev.fspecificaTion
        item.fdescripTion = ev.fdescripTion
        item.unitName = ev.funitName
        item.fpriceunit = ev.fpurchasepriceUnit
        item.fpriceunitid = ev.fpurchasepriceUnitId
      }
      this.isMateria = false
    },
    // 数据字典弹窗
    cliUnit(ev) {
      this.funit = ev
      this.unitVisabled = true
    },
    // 数据字典选中
    selUnit(ev) {
      if (ev.fid) {
        if (this.funit === 'SX_PAYCONDITION') { // 付款条件
          this.prodValue.fpaycondition = ev.fname
          this.prodValue.fpayconditionId = ev.fid
        } else if (this.funit === 'SX_SETTLETYPE') { // 结算方式
          this.prodValue.fsettletype = ev.fname
          this.prodValue.fsettletypeId = ev.fid
        }
      }
      this.unitVisabled = false
    },
    // 新增行
    newLine(ev) {
      const DATA = {
        fqty: 0,
        fmodel: '',
        fpaeztext1: '',
        unitName: '',
        fmaterialId: 0,
        fspecificaTion: '',
        funitId: 0,
        fstockQty: 0,
        fprice: 0,
        ftaxPrice: 0,
        ftaxRate: 0,
        fdescripTion: '',
        fdeliveryDate: '',
        fnumber: '',
        fpriceunit: '',
        fentryId: 0,
        fstockUnitId: 0
      }
      if (ev === 1) {
        this.tableData.push(DATA)
      } else {
        this.tableData.splice(this.indexSelf, 1)
      }
    },
    // 单击行
    rowClick(row) {
      this.indexSelf = row.index
    },
    // 点击单元格
    cellClick(row, column, cell, event) {
      this.property = column.property
      this.subscript = row.index
    },
    // 批量填充
    batchFill() {
      const item = this.tableData[this.subscript][this.property]
      this.tableData.map((res, index) => {
        if (index >= this.subscript) {
          res[this.property] = item
        }
      })
    },
    // 监听实退数量
    numQty(index) {
      const item = this.tableData[index]
      item.freplenishQty = item.frmrealqty
      item.fkeapamtQty = item.frmrealqty
    },
    // 公共函数
    toExamineFun(api, ev) {
      const DATA = {
        Numbers: [this.prodValue.fbillNo],
        entitys: ev === 1 ? this.entry : [],
        update: {
          ...this.prodValue,
          details: this.tableData
        }
      }
      api(DATA).then(res => {
        if (res.code !== 0) {
          this.$confirm(res.message, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'error'
          })
          return
        }
        this.queryTSalOrderNtry()
        this.innerHTM = ''
        res.data.forEach(res => {
          this.innerHTM += '<div>' + res + '</div>'
        })
        this.$notify.warning({
          title: '提示',
          message: this.innerHTM,
          duration: 3000, offset: 50,
          dangerouslyUseHTMLString: true
        })
      })
    },
    // 审核
    audit(ev) {
      this.entry = []
      this.tableData.forEach(res => {
        this.entry.push({
          fsourcebillno: this.prodValue.fbillNo,
          fcodefnumber: res.fcodefnumber,
          fmaterialid: res.fmaterialId,
          fmaterialnumber: res.fnumber,
          fmoentryid: res.fentryId,
          fqty: res.frmrealqty,
          funitid: res.funitId,
          isRaw: res.isRaw
        })
      })
      const api = ev === 1 ? purMrbAudit : purMrbUnAudit
      this.toExamineFun(api, ev)
    },
    // 提交
    submit(ev) {
      const api = ev === 1 ? purMrbSubmit : purMrbAuSubmit
      this.toExamineFun(api)
    },
    // 提交
    using(ev) {
      const api = ev === 1 ? purMrbdisable : purMrbUndisable
      this.toExamineFun(api)
    },
    // 删除
    delPublic() {
      if (this.isDisabled) {
        this.$confirm('请先反审核后再删除', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        })
        return
      }
      this.$confirm('确定要永久删除该订单么？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        const DATA = { Numbers: [this.prodValue.fbillNo] }
        purMrbDelete(DATA).then(res => {
          if (res.code === 0) {
            // 关闭当前页面
            this.$store.dispatch('tagsView/guanbi', this.$route)
            this.$router.push({ path: '/returnMaterList' })
            this.$message({ showClose: true, message: res.message, type: 'success' })
          } else {
            this.$confirm(res.message, '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'error'
            })
          }
        })
      })
    },
    // 上查、下查
    check(ev) {
      this.fentryData = []
      this.tableData.forEach(res => {
        this.fentryData.push(res.fentryId)
      })
      this.cha = ev
      this.upDownVis = true
    },
    // 下推
    pushDown() {
      this.isdanjuDialog = true
      this.orderLX = this.$t('menu.payable')
      this.orderWat(this.$t('menu.payable'))
    },
    orderWat(ev) {
      if (ev === this.$t('menu.payable')) {
        this.purpoorder('SX_PAYABLEBILLTYPE')
        this.convert = this.$t('market.cgrkzyf') // '采购退库单至应付单'
        this.fbillTypeId = 1249
      }
    },
    // 采购退库单单据
    async purpoorder(ev) {
      const { data: RES } = await queryViewItem({ viewName: ev })
      this.billTypeData = RES.list
    },
    // 下推采购退库单
    pushDownOrder() {
      this.fentryData = []
      this.tableData.forEach(res => {
        this.fentryData.push(res.fentryId)
      })
      const DATA = {
        SoucrceIds: [this.prodValue.fid],
        EntryIds: this.fentryData,
        fbillTypeId: this.fbillTypeId
      }
      if (this.orderLX === this.$t('menu.payable')) {
        returnPushToFinPayable(DATA).then(res => {
          if (res.code === 0) {
            this.$router.push({
              path: `/payableDetail/${res.data.fid}`
            })
            this.isdanjuDialog = false
          } else {
            this.$confirm(res.message, '提示', {
              confirmButtonText: '确定',
              type: 'error'
            })
          }
        })
      }
    },
    // 套打A4
    queryReportForm(ev) {
      const FNUMBER = this.prodValue.fbillNo
      if (ev === 1) {
        this.$router.push({ path: `/returnMaterTong/${FNUMBER}` })
      } else {
        this.$router.push({ path: `/returnMaterLian/${FNUMBER}` })
      }
    },
    // 其他
    handleOther(tab) {
      if (tab.name === 'log') {
        this.$refs.log.otherlog()
      }
    }
  }
}
</script>
<style scoped lang="scss">
.editReturnMater {
  @include listBom;
  .tabs{
    &::v-deep .el-tabs__content {
      min-height: calc(100vh - 180px);
      overflow-y: auto;
    }
  }
  .el-input::v-deep .el-input__inner {
    height: 30px;
    line-height: 30px;
  }
  .tabPosit {
    padding: 5px;
    box-shadow: 0 0 2px #aaa;
    position: absolute;
    top: 3.5vh;
    left: 0;
    background-color: rgba(255, 255, 255, 1);
    z-index: 99999!important;
  }
  .tabPosit1 {
    padding: 5px;
    box-shadow: 0 0 2px #aaa;
    position: absolute;
    top: -25.69vh;
    left:0;
    background-color: rgba(255, 255, 255, 1);
    z-index: 9999;
  }
  .el-tabs {
    &::v-deep.el-tabs__header {
      margin: 0 0 5px;
    }
    .el-form {
      display: flex;
      flex-wrap: wrap;

      .el-form-item {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        height: 37px;
        width: 275px;
        min-width: 246px;
        margin-bottom: 3px;
        .btnType{
          margin-right: 20px;
        }
        .el-date-editor.el-input{
          width: 100% !important;
        }
        .el-select{
          width: 100%;
        }
      }
    }
  }
}

.el-input__icon {
  cursor: pointer;
}

</style>
